package lab.anoper.juc.threadpool;

import java.util.concurrent.*;

/**
 * @author 闫家洪（yanjiahong@vcredit.com）
 * @since 2024/12/12
 */
public class TheadPoolDemo {
    public static void main(String[] args) throws Exception {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                1,
                2,
                10L, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10));
        executor.allowCoreThreadTimeOut(true);

        Callable<String> c = () -> {
            Thread.sleep(1000);
            return "hello";
        };

        Future<String> f = executor.submit(c);
        System.out.println(f);
        System.out.println(f.get());
    }
}
